<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "site_info".
 *
 * @property integer $id
 * @property string $title
 * @property string $text
 * @property string $create_at
 */
class SiteInfo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'site_info';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['text'], 'required'],
            [['text'], 'string'],
            [['create_at'], 'safe'],
            [['title'], 'string', 'max' => 100],
            [['title'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '标题',
            'text' => '文章内容',
            'create_at' => '创建时间',
        ];
    }

    public function beforeValidate()
    {

        $this->create_at = date("Y-m-d H:i:s");
        return parent::beforeValidate(); // TODO: Change the autogenerated stub
    }
}
